<template>
  <div class="user-page">
    <div class="My_title__39w3V">
      <img
        class="My_bg__2j-VX"
        src="http://liufusong.top:8080/img/profile/bg.png"
        alt="背景图"
      />

      <div class="My_info__eOYeg">
        <div class="My_myIcon__3cKIV">
          <img
            class="My_avatar__2Fbh7"
            src="http://liufusong.top:8080/img/profile/avatar.png"
            alt="icon"
          />
        </div>

        <div class="user">
          <p>{{ nickname }}</p>
          <van-button type="primary" @click="toLogin">马上登录</van-button>
        </div>
      </div>
    </div>
    <van-grid class="mt20" :column-num="3">
      <van-grid-item to="/sc" icon="star-o" text="我的收藏" />
      <van-grid-item to="/rent" icon="send-gift-o" text="我的出租" />
      <van-grid-item icon="service-o" text="看房记录" />
      <van-grid-item icon="notes-o" text="成为房主" />
      <van-grid-item icon="user-circle-o" text="个人资料" />
      <van-grid-item icon="friends-o" text="联系我们" />
    </van-grid>
    <div class="mt200">
      <img
        class="bgc"
        src="http://liufusong.top:8080/img/profile/join.png"
        alt=""
      />
    </div>
  </div>
</template>

<script>
import { getUser } from "@/api/user";
export default {
  name: "user-page",
  data() {
    return {
      nickname: "",
      avatar:''
    };
  },
  async created() {
    const { body } = await getUser();
    this.nickname = body.nickname;
    this.avatar=body.avatar
  },
  methods: {
    toLogin() {
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="less" scoped>
.bgc {
  // height: 100px;
  width: 100%;
}
.mt200 {
  margin-top: 20px;
  //  opacity: 0.8;
}
.mt20 {
  margin-top: 20px;
}
.user {
  position: relative;
  transform: translateY(-50%);
}
.My_myIcon__3cKIV {
  position: relative;
  transform: translateY(-50%);
  border-radius: 50%;
  width: 70px;
  height: 70px;
  border: 5px solid #f5f5f5;
  display: inline-block;
  box-shadow: 0 2px 2px #bdbdbd;
}
.My_avatar__2Fbh7 {
  width: 100%;
  border-radius: 50%;
}
.My_title__39w3V {
  min-height: 300px;
  position: relative;
}
.My_bg__2j-VX {
  width: 100%;
}
.My_info__eOYeg {
  position: absolute;
  background: #fff;
  width: 85%;
  height: 40%;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 10px 3px #ddd;
  margin: 50px auto 0;
  padding: 0 20px;
  text-align: center;
  font-size: 13px;
  opacity: 0.7;
}
</style>
